Fix crash in -^ generating doc list
authorRobert Lipe <robertlipe@gpsbabel.org>
Tue, 31 Jul 2018 00:29:14 +0000 (19:29 -0500)
committerRobert Lipe <robertlipe@gpsbabel.org>
Tue, 31 Jul 2018 00:29:14 +0000 (19:29 -0500)
vecs_t is no longer a struct of POD. It’s now a class and has to be
allocated by new. I hope to not have to rathole in vets for this change
because it’s full of scary memory management like this.

vecs.cc

diff --git a/vecs.cc b/vecs.cc
index f04bfd74dbb77bbea66fbed679b2ae3e35f66739..b4c2d4a73a0d3d6154afc4b6e92b17d24e67ecc5 100644 (file)
--- a/vecs.cc
+++ b/vecs.cc
@@ -23,6 +23,8 @@
 #include "csv_util.h"
 #include "gbversion.h"
 #include "inifile.h"
+#include "QtCore/QDebug"
+#include <cstdio>
 #include <cstdio>
 #include <cstdlib> // qsort
 
@@ -1483,7 +1485,7 @@ sort_and_unify_vecs(int* ctp)
   /* Walk the style list, parse the entries, dummy up a "normal" vec */
   for (style_vecs_t* svec = style_list; svec->name; svec++, i++)  {
     xcsv_read_internal_style(svec->style_buf);
-    svp[i] = (vecs_t*) xcalloc(1, sizeof** svp);
+    svp[i] = new vecs_t;
     svp[i]->name = svec->name;
     svp[i]->vec = (ff_vecs_t*) xmalloc(sizeof(*svp[i]->vec));
     svp[i]->extensions = xcsv_file.extension;
@@ -1677,7 +1679,6 @@ disp_formats(int version)
   vecs_t** svp;
   vecs_t* vec;
   int vc = 0;
-
   switch (version) {
   case 0:
   case 1:
@@ -1701,7 +1702,7 @@ disp_formats(int version)
         disp_v2(vec->vec);
       }
       printf("%s\t%s\t%s%s%s\n", vec->name,
-             CSTR(vec->extensions) ? CSTR(vec->extensions) : "",
+             !vec->extensions.isEmpty() ? CSTR(vec->extensions) : "",
              CSTR(vec->desc),
              version >= 3 ? "\t" : "",
              version >= 3 ? vec->parent : "");